/**
 * 
 */
package com.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.aspect.ResponseFormat;
import com.exception.ServiceException;
import com.service.UserService;




/**
 *
 *@类名称：DemoController.java
 *@类描述：样例控制层
 *@创建人：zhongy
 *@创建时间：2017年4月3日-下午1:44:44
 *@修改备注:
 *@version 
 *
 *
 *
 *1、方法向外抛出异常ServiceException
 *2、@ResponseFormatAnn 进行返回值格式化+异常处理
 *3、@Controller 不需要指定RequestMapping
 *4、@ResponseBody 表示返回值 调用配置的json串
 *5、@RequestMapping 方法上必须指定
 *
 *命名规范：
 *1、RequestMapping 中小写命名;尽量 tableName_action 
 *
 *
 *
 *
 */

@Controller
public class DemoController extends BaseController{
//	@Resource
//	private DemoService demoService;

	@Resource
	private UserService userService;
	
	@ResponseFormat(needLogin=false) 
	@RequestMapping(value="/user_get")
	@ResponseBody
	public Object getUser(HttpServletRequest request, HttpServletResponse response) throws ServiceException{
		
		return userService.get(2l);

	}
//	@ResponseFormat(needLogin=false)
//	@RequestMapping(value="/user_getbyid")
//	@ResponseBody
//	public User getUserById(HttpServletRequest request, HttpServletResponse response,Long id){
//		return demoService.getUserById(id);
//	}
//	
//	//http://localhost:8080/wnservice/api/demo/getUserByCondition?state=0&name=bao
//	@ResponseFormat(needLogin=false)
//	@RequestMapping(value="/user_getbycondition")
//	@ResponseBody
//	public Object getUserByCondition(HttpServletRequest request, HttpServletResponse response,String name,String state){
//		return demoService.getUserByCondition(name, state);
//	}
//	
//	//http://localhost:8080/wnservice/api/demo/insertUser?userName=test11&trueName=test222
//	@ResponseFormat(needLogin=false)
//	@RequestMapping(value="/user_insert")
//	@ResponseBody
//	public Object insertUser(HttpServletRequest request, HttpServletResponse response,User user){
//		Long id=demoService.insertUser(user);
//		System.out.println(user.getId());
//		return id;
//	}
//	//http://localhost:8080/wnservice/api/demo/updateUser?state=1&userName=test11
//	@ResponseFormat(needLogin=false)
//	@RequestMapping(value="/user_update")
//	@ResponseBody
//	public Object updateUser(HttpServletRequest request, HttpServletResponse response,User user){
//		return demoService.updateUser(user);
//	}
//	//http://localhost:8080/wnservice/api/demo/deleteUserById?id=413
//	@ResponseFormat(needLogin=false)
//	@RequestMapping(value="/user_deletebyid")
//	@ResponseBody
//	public Object deleteUserById(HttpServletRequest request, HttpServletResponse response,User user){
//		return demoService.deleteUserById(user.getId());
//	}
//	
//	@ResponseFormat(needLogin=false)
//	@RequestMapping(value="/sql_test")
//	@ResponseBody
//	public Object sqlTest(HttpServletRequest request, HttpServletResponse response){
//	
//		return "";
//	}
	
	
	
}
